package top.lshaci.learning.nio.zerocopy;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

/**
 * NewIOService
 *
 * @author lshaci
 * @since 1.0.0
 */
public class NewIOServer {

    public static void main(String[] args) throws IOException {
        InetSocketAddress address = new InetSocketAddress(6688);

        ServerSocketChannel server = ServerSocketChannel.open();

        server.bind(address);

        ByteBuffer buffer = ByteBuffer.allocate(8192);

        while (true) {
            SocketChannel client = server.accept();
            int read = 0;
            while ((read = client.read(buffer)) != -1) {
                buffer.rewind();
            }
        }
    }
}
